<?php

include 'inc/common.inc.php';
include 'MMyinfo.class.php';
include 'MCheckUser.class.php';
include 'authcode.class.php';

class Controller extends BaseController
{
	public function informInitialize()
	{
		$userTel = $this->get_session("userTel");
		$db = new MMyinfo();
		$item = $db->selectInformation($userTel,"doing");
		$url = new authcode();
		foreach($item as $keyOri=>$valueOri)
		{
			$temp = $valueOri['gatherId'];
			$item[$keyOri]['url'] = $url->keycode($temp,'ENCODE');
		}
		return $item;
	}
	
	public function attendParty()
	{
		$userTel = $this->get_session("userTel");
		$db = new MMyinfo();
		$item = $db->selectAttend($userTel,"doing");
		$url = new authcode();
		foreach($item as $keyOri=>$valueOri)
		{
			$temp = $valueOri['gatherId']."#".$userTel;
			$item[$keyOri]['url'] = $url->keycode($temp,'ENCODE');
		}
		return $item;
	}
	
	public function preParty()
	{
		$userTel = $this->get_session("userTel");
		$db = new MMyinfo();
		$item = $db->selectPreParty($userTel);
		return $item;
	}
	
	public function clearCookieAction()
	{
		parent::clearCookie();
		$dbCheckUser = new MCheckUser();
		$dbCheckUser->clearSessionId();
		if(isset($_SESSION['userTel']))
		{
			unset($_SESSION['userTel']);
		}
		$this->_msg->set(array("desc"=>"清理cookie成功","return_code"=>1));
		echo $this->_msg;
	}
}

$control = new Controller();
$control->run();
$dbCheck = new MCheckUser();
//echo $_COOKIE['PHPSESSID'];
//echo session_id();
//echo $_SESSION['userTel'];
if(!$control->get_action_name() && $dbCheck->checkSessionId())
{
	$information = $control->informInitialize();
	//print_r($information);
	$attendInfor = $control->attendParty();
	//print_r($attendInfor);
	$preInfor = $control->preParty();
	$nowDate = date('Y-m-d');
	include template('myinfo.html');
}
else if(!$control->get_action_name() && !$dbCheck->checkSessionId())
{
	header("Location: index.php");
}
?>